/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "GRADE", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Grade.findAll", query = "SELECT g FROM Grade g"),
    @NamedQuery(name = "Grade.findByIdGrade", query = "SELECT g FROM Grade g WHERE g.idGrade = :idGrade"),
    @NamedQuery(name = "Grade.findByGrade", query = "SELECT g FROM Grade g WHERE g.grade = :grade")})
public class Grade implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_GRADE", nullable = false)
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Short idGrade;
    @Basic(optional = false)
    @Column(name = "GRADE", nullable = false, length = 8)
    private String grade;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "grade")
    private Collection<TraderGrade> traderGradeCollection;

    public Grade() {
    }

    public Grade(Short idGrade) {
        this.idGrade = idGrade;
    }

    public Grade(Short idGrade, String grade) {
        this.idGrade = idGrade;
        this.grade = grade;
    }

    public Short getIdGrade() {
        return idGrade;
    }

    public void setIdGrade(Short idGrade) {
        this.idGrade = idGrade;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    @XmlTransient
    public Collection<TraderGrade> getTraderGradeCollection() {
        return traderGradeCollection;
    }

    public void setTraderGradeCollection(Collection<TraderGrade> traderGradeCollection) {
        this.traderGradeCollection = traderGradeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idGrade != null ? idGrade.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Grade)) {
            return false;
        }
        Grade other = (Grade) object;
        if ((this.idGrade == null && other.idGrade != null) || (this.idGrade != null && !this.idGrade.equals(other.idGrade))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.Grade[ idGrade=" + idGrade + " ]";
    }
    
}
